package com.nosweattechnet.locationsearch;

import com.nosweattechnet.mapmyway.R;

import android.location.Criteria;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.support.v4.app.NavUtils;

//Runs a radius search from information that the user enters into a text box
public class VariableLocationSearchActivity extends SuperLocationSearchActivity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    	setContentView(R.layout.activity_location_search);
    	Button b=(Button) this.findViewById(R.id.radiusSearchButton);
    	b.setOnClickListener(new OnClickListener(){
			public void onClick(View v) {
				EditText radiusText=(EditText) findViewById(R.id.radiusText);
				float r;
				try{
					r=Float.parseFloat(radiusText.getText().toString());
				}catch(NumberFormatException e){
					r=0;
				}
				radiusSearch(r);
			}
    	});
    }
    
    protected Criteria getCriteria(){
    	return new Criteria();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_location_search, menu);
        return true;
    }

    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                NavUtils.navigateUpFromSameTask(this);
                return true;
        }
        return super.onOptionsItemSelected(item);
    }

}
